home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / TRANSLAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-30  |  1.2 KB  |  55 lines

  1. #include "global.h"
  2. #include "commands.h"
  3. #include "files.h"
  4.  
  5. #if !defined(_lint)
  6. static char rcsid[] OPTIONAL = "$Id: translat.c,v 1.11 1997/07/31 00:44:20 root Exp root $";
  7. #endif
  8.  
  9. #ifdef TRANSLATE
  10. char *translate (register char *searchfor, int *didwe);
  11.  
  12.  
  13. char *
  14. translate (searchfor, didwe)
  15. register char *searchfor;
  16. int *didwe;
  17. {
  18. FILE *fp;
  19. char buf[256];
  20. char *retval, *trans;
  21.  
  22.     retval = strdup (searchfor);
  23.     *didwe = 0;
  24.     sprintf (buf, "%s/translat", ETCdir);
  25.     if ((fp = fopen (buf, "rt")) == NULL)
  26.         return (retval);
  27.     while (!feof(fp))    {
  28.         (void) fgets(buf, 256, fp);
  29.         if (feof(fp))
  30.             continue;
  31.         rip (buf);
  32.         if ((*buf == '#')  || !*buf)
  33.             continue;    /* skip comment lines */
  34.         trans = skipwhite(buf);
  35.         if (trans != buf)    /* can't start with white space */
  36.             continue;
  37.         trans = skipnonwhite(buf);
  38.         if (!*trans)    /* invalid line - no translate name */
  39.             continue;
  40.         *trans++ = 0;
  41.         trans = skipwhite(trans);
  42.         if (strnicmp (searchfor, buf, strlen(buf)))
  43.             continue;    /* no match */
  44.         free (retval);
  45.         retval = strdup (trans);
  46.         *didwe = 1;
  47.         break;
  48.     }
  49.     (void) fclose (fp);
  50.     return (retval);
  51. }
  52.  
  53.  
  54. #endif /* TRANSLATE */
  55.